In [1]:
#%matplotlib inline
# Import all the programs we want to use. If this gives an error, then you need to add these to your python path.
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from pandas import DataFrame, Series # for convenience
import pims
import trackpy as tp
#import holopy as hp
import os
#import av
import scipy
import scipy.optimize as sco
import seaborn as sns
%pylab inline
# tell python how to display images
#%matplotlib notebook
In [2]:
scaling = 0.08431 #um/pixel
mpp = scaling
fps = 11.935
moviename = 'tracer+janus_3%_H2O2_5(green)2016-06-14'
In [3]:
1/fps
Out[3]:
In [4]:
os.chdir('C:\\Users\\Viva\\Desktop\\EPJ folder\\analysis')
In [5]:
t1 = pd.read_pickle('filtered_data_tracer+janus_3%_H2O2_5(green)2016-06-14_pickled.pkl')
In [6]:
tm = pd.read_pickle('filtered_data_with_drift_subtracted_tracer+janus_3%_H2O2_5(green)2016-06-14_pickled.pkl')
In [7]:
fpscontrol = 11.959
t1control = pd.read_pickle('filtered_data_tracer+janus_no_H2O2_3(red)2016-06-14_pickled.pkl')
In [8]:
tmcontrolfilename = 'filtered_data_with_drift_subtracted_tracer+janus_no_H2O2_3(red)2016-06-14_pickled.pkl'
tmcontrol = pd.read_pickle(tmcontrolfilename)
controlmoviename = 'tracer+janus_no_H2O2_3(red)2016-06-14'
In [9]:
plt.axis('equal')
ax = tp.plot_traj(t1, mpp = scaling, legend=False)
In [10]:
plt.axis('equal')
ax = tp.plot_traj(tm, mpp = scaling, legend=False)
In [11]:
d = tp.compute_drift(t1, smoothing=15)
#plt.figure()
d.plot(grid=False)
plt.title('Translational drift in ' + moviename + '\n')
plt.ylabel('pixels')
Out[11]:
In [12]:
d.head()
Out[12]:
In [13]:
dmicrons= d*mpp
dmicrons.index = d.index /fps
dmicrons.index.name = 'time (s)'
dmicrons.head()
Out[13]:
In [14]:
dmicrons.plot()
plt.title('Translational drift in ' + moviename + '\n')
plt.ylabel('Ensemble translational drift ($\mathrm{\mu}$m)')
Out[14]:
In [49]:
print(dmicrons.index[0] == 1/fps)
1/fps
Out[49]:
In [51]:
drift = dmicrons.diff()
velocitydf = (dmicrons.diff()/ (1/fps))
velocitydf.plot()
#xlabel('Time (s)')
ylabel("Ensemble mean velocity ($\mathrm{\mu}$m/s)")
pltdrift.plot()
ylabel("Ensemble mean drift ($\mathrm{\mu}$m)")
title("$\Delta{}t = 0.0838$ sec", loc='right').figure()
drift.plot()
ylabel("Ensemble mean drift ($\mathrm{\mu}$m)")
title("$\Delta{}t = 0.0838$ sec", loc='right')
Out[51]:
In [63]:
velocitydf['speed'] = sqrt(velocitydf.x**2 + velocitydf.y**2)
In [60]:
drift['distance']=sqrt(drift.x**2 + drift.y**2)
drift.distance.plot()
ylabel("Ensemble mean drift ($\mathrm{\mu}$m)")
plt.title("$\Delta{}t = 0.0838$ sec", loc='right')
ylabel("Ensemble mean drift ($\mathrm{\mu}$m)")
title("$\Delta{}t = 0.0838$ sec", loc='right')
Out[60]:
In [59]:
drift.describe()
Out[59]:
In [18]:
velocitydf.describe()
Out[18]:
In [19]:
velocitydf.speed.hist(bins=50)
xlabel("Lateral translational drift speed ($\mathrm{\mu}$m/s)")
ylabel("Occurrences")
Out[19]:
In [20]:
tm.head()
Out[20]:
In [ ]:
In [21]:
tracks = t1['particle'].astype(int).unique()
print size(tracks)
if size(tracks) < 400:
print tracks
In [22]:
traj4 = tm[tm['particle']==tracks[4]]
In [23]:
#plot(traj4.x*mpp, traj4.y*mpp)
#plt.axis('equal')
fig1 = plt.figure()
plt.axis('equal')
ax1 = tp.plot_traj(traj4, mpp = scaling, legend=False)
ax1.set_xlabel('x ($\mathrm{\mu}$m)')
plt.figure()
plot(traj4.frame/fps, traj4.x*mpp)
#plot(traj4.frame/fps, traj4.y*mpp)
xlabel("Time (s)")
ylabel('x position (s)')
Out[23]:
In [24]:
plt.figure()
xlabel("Time (s)")
ylabel('y position (microns)')
title('Trajectory of drift-subtracted particles')# in\n' + moviename)
count = 0
for i in tracks:
if (tm[tm['particle']==i].x*mpp)[1]>80:
continue
plot(tm[tm['particle']==i].frame/fps, tm[tm['particle']==i].y*mpp)
count = count+1
print(count)
plt.figure()
xlabel("Time (s)")
ylabel('y position (microns)')
count = 0
for i in tracks[::4]:
if (tm[tm['particle']==i].x*mpp)[1]>80:
continue
plot(tm[tm['particle']==i].frame/fps, tm[tm['particle']==i].y*mpp)
count = count+1
print(count)
title('Trajectory of some of drift-subtracted particles')# in\n' + moviename)
plt.figure()
xlabel("Time (s)")
ylabel('y position (microns)')
count = 0
for i in tracks[::4]:
if (tm[tm['particle']==i].x*mpp)[1]>80:
continue
plot(t1[t1['particle']==i].frame/fps, t1[t1['particle']==i].y*mpp)
count = count+1
print(count)
title('Raw Trajectory of some of particles')# in\n' + moviename)
Out[24]:
In [25]:
plt.figure()
xlabel("Time (s)")
ylabel('x position (microns)')
title('Trajectory of drift-subtracted particles')# in\n' + moviename)
for i in tracks:
if (tm[tm['particle']==i].x*mpp)[1]>80:
continue
plot(tm[tm['particle']==i].frame/fps, tm[tm['particle']==i].x*mpp)
plt.figure()
xlabel("Time (s)")
ylabel('x position (microns)')
title('Trajectory of some of drift-subtracted particles')# in\n' + moviename)
for i in tracks[::4]:
if (tm[tm['particle']==i].x*mpp)[1]>80:
continue
plot(tm[tm['particle']==i].frame/fps, tm[tm['particle']==i].x*mpp)
plt.figure()
xlabel("Time (s)")
ylabel('x position (microns)')
title('Raw Trajectory of particles')# in\n' + moviename)
for i in tracks:
if (tm[tm['particle']==i].x*mpp)[1]>80:
continue
plot(t1[t1['particle']==i].frame/fps, t1[t1['particle']==i].x*mpp)
plt.figure()
xlabel("Time (s)")
ylabel('x position (microns)')
title('Raw Trajectory of some of particles')# in\n' + moviename)
for i in tracks[::4]:
if (tm[tm['particle']==i].x*mpp)[1]>80:
continue
plot(t1[t1['particle']==i].frame/fps, t1[t1['particle']==i].x*mpp)
In [26]:
i=12
velx12 = fps*(tm[tm['particle']==i].x*mpp).diff()
#print(tm[tm['particle']==i].head())
#velx12.head()
In [27]:
plt.figure()
xlabel("Time (frame)")
ylabel('x velocity (microns/s)')
title('Velocity of some of drift-subtracted particles')# in\n' + moviename)
for i in tracks[::4]:
if (tm[tm['particle']==i].x*mpp)[1]>80:
continue
tm[tm['particle']==i].x*mpp
plot(tm[tm['particle']==i].frame, fps*(tm[tm['particle']==i].x*mpp).diff())
try:
tmvel.append(fps*(tm[tm['particle']==i].x*mpp), ignore_index=False)
except NameError:
tmvel = fps*(tm[tm['particle']==i].x*mpp)
In [28]:
try:
del(tmxvel)
except NameError:
print('No problem')
plt.figure()
xlabel("Time (s)")
ylabel('x velocity (microns/s)')
title('Velocity of some of drift-subtracted particles')# in\n' + moviename)
for i in tracks:
if (tm[tm['particle']==i].x*mpp)[1]>80:
continue
#tm[tm['particle']==i].x*mpp
plot(tm[tm['particle']==i].frame/fps, fps*(tm[tm['particle']==i].x*mpp).diff())
try:
tmxvel=tmxvel.append(fps*(tm[tm['particle']==i].x*mpp).diff(), ignore_index=False)
except NameError:
tmxvel = fps*(tm[tm['particle']==i].x*mpp).diff()
In [29]:
tmxvel.describe()
Out[29]:
In [30]:
tmxvel.hist(bins=200)
xlabel("x-velocity of drift-subtracted particles ($\mathrm{\mu}$m/s)")
ylabel('Occurrences')
Out[30]:
In [31]:
try:
del(tmyvel)
except NameError:
print('No problem')
plt.figure()
xlabel("Time (s)")
ylabel('y velocity (microns/s)')
title('Velocity of some of drift-subtracted particles')# in\n' + moviename)
for i in tracks:
if (tm[tm['particle']==i].x*mpp)[1]>80:
continue
#tm[tm['particle']==i].y*mpp
plot(tm[tm['particle']==i].frame/fps, fps*(tm[tm['particle']==i].y*mpp).diff())
try:
tmyvel=tmyvel.append(fps*(tm[tm['particle']==i].y*mpp).diff(), ignore_index=False)
except NameError:
tmyvel = fps*(tm[tm['particle']==i].y*mpp).diff()
In [32]:
tmyvel.hist(bins=200)
xlabel("y-velocity of drift subtracted particles ($\mathrm{\mu}$m/s)")
ylabel('Occurrences')
tmyvel.describe()
Out[32]:
In [42]:
try:
del(tmspeed)
except NameError:
print('No problem')
plt.figure()
xlabel("Time (s)")
ylabel('speed (microns/s)')
title('Speed of drift-subtracted particles')# in\n' + moviename)
for i in tracks:
if (tm[tm['particle']==i].x*mpp)[1]>80:
continue
#tm[tm['particle']==i].y*mpp
plot(tm[tm['particle']==i].frame/fps,
fps*sqrt(((tm[tm['particle']==i].x*mpp).diff())**2+
((tm[tm['particle']==i].y*mpp).diff())**2))
try:
tmspeed=tmspeed.append(
fps*sqrt(((tm[tm['particle']==i].x*mpp).diff())**2
+((tm[tm['particle']==i].y*mpp).diff())**2),
ignore_index=False)
tmdisplacement=tmdisplacement.append(
sqrt(((tm[tm['particle']==i].x*mpp).diff())**2
+((tm[tm['particle']==i].y*mpp).diff())**2),
ignore_index=False)
except NameError:
tmspeed = fps*sqrt(((tm[tm['particle']==i].x*mpp).diff())**2
+((tm[tm['particle']==i].y*mpp).diff())**2)
tmdisplacement=sqrt(((tm[tm['particle']==i].x*mpp).diff())**2
+((tm[tm['particle']==i].y*mpp).diff())**2)
In [46]:
tmspeed.hist(bins=300)
xlabel("Speed of drift-subtracted particles ($\mathrm{\mu}$m/s)")
ylabel('Occurrences')
xlim(xmin=0,xmax=20)
tmspeed.describe()
plt.figure()
tmdisplacement.hist(bins=300)
xlim(xmin=0,xmax=1.5)
Out[46]:
In [40]:
try:
del(t1speed)
except NameError:
print('No problem')
try:
del(t1displacement)
except NameError:
print('No problem')
plt.figure()
xlabel("Time (s)")
ylabel('speed (microns/s)')
title('Raw Speed of particles')# in\n' + moviename)
for i in tracks:
if (tm[tm['particle']==i].x*mpp)[1]>80:
continue
#tm[tm['particle']==i].y*mpp
plot(t1[t1['particle']==i].frame/fps,
fps*sqrt(((t1[t1['particle']==i].x*mpp).diff())**2+
((t1[t1['particle']==i].y*mpp).diff())**2))
try:
t1speed=t1speed.append(
fps*sqrt(((t1[t1['particle']==i].x*mpp).diff())**2
+((t1[t1['particle']==i].y*mpp).diff())**2),
ignore_index=False)
t1displacement = t1displacement.append(
sqrt(((t1[t1['particle']==i].x*mpp).diff())**2
+((t1[t1['particle']==i].y*mpp).diff())**2),
ignore_index=False)
except NameError:
t1speed = fps*sqrt(((t1[t1['particle']==i].x*mpp).diff())**2
+((t1[t1['particle']==i].y*mpp).diff())**2)
t1displacement = sqrt(((t1[t1['particle']==i].x*mpp).diff())**2
+((t1[t1['particle']==i].y*mpp).diff())**2)
In [36]:
np.arange(0,15,.5)
Out[36]:
In [37]:
sns.set(style='ticks')
sns.set_context('notebook')
plt.rcParams.update({'xtick.major.size': 3 ,
'ytick.major.size': 3,
'axes.linewidth' : .5,
'xtick.minor.size': 1.5 ,
'ytick.minor.size': 1.5})
plt.subplot(3,1,1)
velocitydf.speed.hist(bins=np.arange(0,15,.1))
xlabel("Lateral translational drift speed ($\mathrm{\mu}$m/s)")
ylabel("Occurrences")
xlim(xmin=0,xmax=15)
ax=plt.gca()
ax.grid(False)
plt.subplot(3,1,3)
tmspeed.hist(bins=np.arange(0,50,.1))
xlabel("Lateral speed of drift-subtracted Janus particles ($\mathrm{\mu}$m/s)")
ylabel('Occurrences')
xlim(xmin=0,xmax=15)
ax=plt.gca()
ax.grid(False)
print("Drift subtracted:")
print(tmspeed.describe())
plt.subplot(3,1,2)
t1speed.hist(bins=np.arange(0,15,.1))
xlabel("Raw lateral speed of Janus particles ($\mathrm{\mu}$m/s)")
ylabel('Occurrences')
xlim(xmin=0,xmax=15)
ax=plt.gca()
ax.grid(False)
#xlabel("Lateral speed of particles ($\mathrm{\mu}$m/s)")
fig = plt.gcf()
thisheight=5#/1.618
thiswidth=5
fig.set_size_inches(thiswidth,thisheight)
plt.tight_layout()
print("Raw:")
print(t1speed.describe())
In [38]:
sns.set(style='ticks')
sns.set_context('paper')
# 10pt font
font = {'size' : 10}
plt.rc('font', **font)
plt.rcParams.update({'legend.handlelength': 0.5, 'legend.fontsize':10})
plt.rcParams.update({'axes.titlesize' : 10 })
plt.rcParams.update({'axes.linewidth' : .2,
'xtick.major.size': 3 ,'ytick.major.size': 3,
'xtick.minor.size': 1.5 ,'ytick.minor.size': 1.5,
'xtick.labelsize':10, 'ytick.labelsize':10,
'axes.labelpad': 0})
plt.subplot(2,1,1)
velocitydf.speed.hist(bins=np.arange(0,15,.1))
xlabel("Lateral translational drift speed ($\mathrm{\mu}$m/s)")
ylabel("Occurrences")
xlim(xmin=0,xmax=15)
plt.title("C", loc='left')
ax=plt.gca()
ax.grid(False)
plt.subplot(2,1,2)
tmspeed.hist(bins=np.arange(0,50,.1), histtype='step', label="after drift-subtraction", linewidth=1)
#xlabel("Lateral speed of drift-subtracted Janus particles ($\mathrm{\mu}$m/s)")
#ylabel('Occurrences')
xlim(xmin=0,xmax=15)
ax=plt.gca()
ax.grid(False)
print("Drift subtracted:")
print(tmspeed.describe())
#plt.subplot(3,1,2)
t1speed.hist(bins=np.arange(0,15,.1), histtype='step', label="before drift-subtraction", linewidth=1)
xlabel("Lateral speed of Janus particles ($\mathrm{\mu}$m/s)")
ylabel('Occurrences')
xlim(xmin=0,xmax=15)
plt.legend()
plt.title("D", loc='left')
ax=plt.gca()
ax.grid(False)
#xlabel("Lateral speed of particles ($\mathrm{\mu}$m/s)")
fig = plt.gcf()
thisheight=5/1.618
thiswidth=5
fig.set_size_inches(thiswidth,thisheight)
sns.despine();
plt.tight_layout()
print("Raw:")
print(t1speed.describe())
In [64]:
sns.set(style='ticks')
sns.set_context('paper')
# 10pt font
font = {'size' : 10}
plt.rc('font', **font)
plt.rcParams.update({'legend.handlelength': 0.5, 'legend.fontsize':10})
plt.rcParams.update({'axes.titlesize' : 10 })
plt.rcParams.update({'axes.linewidth' : .2,
'xtick.major.size': 3 ,'ytick.major.size': 3,
'xtick.minor.size': 1.5 ,'ytick.minor.size': 1.5,
'xtick.labelsize':10, 'ytick.labelsize':10,
'axes.labelpad': 0})
plt.figure()
velocitydf.speed.hist(bins=np.arange(0,15,.1),histtype='step', label="ensemble drift speed", linewidth=1)
xlabel("Lateral translational drift speed ($\mathrm{\mu}$m/s)")
ylabel("Occurrences")
xlim(xmin=0,xmax=15)
plt.title("C", loc='left')
ax=plt.gca()
ax.grid(False)
#plt.subplot(3,1,2)
t1speed.hist(bins=np.arange(0,15,.1), histtype='step', label="before drift-subtraction", linewidth=1, color="#7a7a7aff")
xlabel("Lateral speed of Janus particles ($\mathrm{\mu}$m/s)")
ylabel('Occurrences')
xlim(xmin=0,xmax=15)
#plt.title("D", loc='left')
ax=plt.gca()
ax.grid(False)
#plt.subplot(2,1,2)
tmspeed.hist(bins=np.arange(0,50,.1), histtype='step', label="after drift-subtraction", linewidth=1, color="k")
#xlabel("Lateral speed of drift-subtracted Janus particles ($\mathrm{\mu}$m/s)")
#ylabel('Occurrences')
xlim(xmin=0,xmax=15)
ax=plt.gca()
ax.grid(False)
print("Drift subtracted:")
print(tmspeed.describe())
plt.legend()
#xlabel("Lateral speed of particles ($\mathrm{\mu}$m/s)")
fig = plt.gcf()
thisheight=1.8
thiswidth=4.3
fig.set_size_inches(thiswidth,thisheight)
sns.despine();
plt.tight_layout()
print("Raw:")
print(t1displacement.describe())
os.chdir('C:\\Users\\Viva\\Desktop\\EPJ folder\\paperfigures')
try:
plt.savefig('particle_speed,' + moviename + '.pdf',
bbox_inches='tight', figsize=(thiswidth, thisheight))
print('pdf saved')
plt.savefig('particle_speed,' + moviename + '.png',
bbox_inches='tight', dpi=600, figsize=(thiswidth, thisheight))
plt.savefig('particle_speed,' + moviename + '.svg',
bbox_inches='tight', figsize=(thiswidth, thisheight))
except IOError:
print('Close the pdf file so I can overwrite it.')
In [67]:
t1displacement.head()
Out[67]:
In [76]:
# *** come back one I've replaced drift.speed
sns.set(style='ticks')
sns.set_context('paper')
# 10pt font
font = {'size' : 10}
plt.rc('font', **font)
plt.rcParams.update({'legend.handlelength': 0.5, 'legend.fontsize':10})
plt.rcParams.update({'axes.titlesize' : 10 })
plt.rcParams.update({'axes.linewidth' : .2,
'xtick.major.size': 2 ,'ytick.major.size': 2,
'xtick.minor.size': .5 ,'ytick.minor.size': .5,
'xtick.labelsize':10, 'ytick.labelsize':10,
'axes.labelpad': 0})
binsequence=np.arange(0,15,.01)
plt.figure()
drift.distance.hist(bins=binsequence,histtype='step', label="ensemble drift", linewidth=1)
xlabel("Translational drift ($\mathrm{\mu}$m)")
ylabel("Occurrences")
xlim(xmin=0,xmax=15)
plt.title("C", loc='left')
title("$\Delta{}t = 0.084$ sec", loc='right')
ax=plt.gca()
ax.grid(False)
#plt.subplot(3,1,2)
t1displacement.hist(bins=binsequence, histtype='step', label="before drift-subtraction", linewidth=1, color="#7a7a7aff")
#xlabel("Distance Janus particles move ($\mathrm{\mu}$m)")
xlabel("$\Delta r$ ($\mathrm{\mu}$m)")
ylabel('Occurrences')
#xlim(xmin=0,xmax=15)
#plt.title("D", loc='left')
ax=plt.gca()
ax.grid(False)
#plt.subplot(2,1,2)
tmdisplacement.hist(bins=binsequence, histtype='step', label="after drift-subtraction", linewidth=1, color="k")
#xlabel("Lateral speed of drift-subtracted Janus particles ($\mathrm{\mu}$m/s)")
#ylabel('Occurrences')
#xlim(xmin=0,xmax=15)
ax=plt.gca()
ax.grid(False)
print("Drift subtracted:")
print(tmspeed.describe())
xlim(0,1.5)
plt.legend()
#xlabel("Lateral speed of particles ($\mathrm{\mu}$m/s)")
fig = plt.gcf()
thisheight=1.8
thiswidth=4.3
fig.set_size_inches(thiswidth,thisheight)
sns.despine();
plt.tight_layout()
print("Raw:")
print(t1displacement.describe())
os.chdir('C:\\Users\\Viva\\Desktop\\EPJ folder\\paperfigures')
try:
plt.savefig('particle_displacement,' + moviename + '.pdf',
bbox_inches='tight', figsize=(thiswidth, thisheight))
print('pdf saved')
plt.savefig('particle_displacement,' + moviename + '.png',
bbox_inches='tight', dpi=600, figsize=(thiswidth, thisheight))
plt.savefig('particle_displacement,' + moviename + '.svg',
bbox_inches='tight', figsize=(thiswidth, thisheight))
except IOError:
print('Close the pdf file so I can overwrite it.')
In [74]:
fps
Out[74]:
In [75]:
1/fps
Out[75]:
In [40]:
plt.figure()
velocitydf.speed.hist(bins=np.arange(0,15,.1))
xlabel("Lateral translational drift speed ($\mathrm{\mu}$m/s)")
ylabel("Occurrences")
xlim(xmin=0,xmax=15)
ax=plt.gca()
ax.grid(False)
#plt.figure()
velocitydf['frame']=d.index
driftyvel = velocitydf[velocitydf.frame> 1100]
print('comparing full movie to drifty end of movie')
driftyvel.speed.hist(bins=np.arange(0,15,.1))
xlabel("Lateral translational drift speed ($\mathrm{\mu}$m/s)")
ylabel("Occurrences")
xlim(xmin=0,xmax=15)
ax=plt.gca()
ax.grid(False)
In [ ]:
In [41]:
velocitydf.head()
Out[41]:
In [42]:
velocitydf.tail()
Out[42]:
In [43]:
t1.head()
Out[43]:
In [44]:
t1_drifty = t1[t1['frame'] > 1100]
tm_drifty = tm[tm['frame'] > 1100]
In [45]:
d_drifty = tp.compute_drift(t1_drifty, smoothing=15)
#plt.figure()
d_drifty.plot(grid=False)
plt.title('Translational drift in ' + moviename + '\n')
plt.ylabel('pixels')
Out[45]:
In [46]:
d_tmdrifty = tp.compute_drift(tm_drifty, smoothing=15)
#plt.figure()
d_tmdrifty.plot(grid=False)
plt.title('Translational drift in ' + moviename + '\n' + 'Should be none, and that\'s true')
Out[46]:
In [47]:
fig1 = plt.figure()
plt.axis('equal')
ax1 = tp.plot_traj(t1_drifty, mpp = scaling, legend=False)
ax1.set_xlabel('x ($\mu$m)')
Out[47]:
In [48]:
fig2 = plt.figure()
plt.axis('equal')
ax2 = tp.plot_traj(tm_drifty, mpp = scaling, legend=False)
In [49]:
size(tm_drifty['particle'].astype(int).unique())
Out[49]:
In [50]:
import seaborn as sns
sns.set(style='ticks')
sns.set_context('paper')
sns.set_palette(sns.husl_palette(22,l=.55))
# Big font
font = {'size' : 10}
plt.rc('font', **font)
plt.rcParams.update({'legend.handlelength': 0})
plt.rcParams.update({'axes.titlesize' : 10 })
plt.rcParams.update({'axes.linewidth' : .2,
'xtick.major.size': 2 ,'ytick.major.size': 2,
'xtick.labelsize':10, 'ytick.labelsize':10})
fig, (ax1, ax2) = plt.subplots(1, 2, sharey=True, sharex=True)
#plt.subplot(1,2, 2)
#ax2 = plt.gca()
plt.axis('equal')
tp.plot_traj(tm_drifty, mpp = scaling, legend=False, ax=ax2)
#tick_params( which='both', pad=2)
#plt.subplot(1,2, 1)
#fig = plt.gcf()
#ax1 = plt.gca()
#plt.figsize=(8,10)
tp.plot_traj(t1_drifty, mpp = scaling, legend=False, ax=ax1)
#tick_params( which='both', pad=2)
plt.axis('equal')
ax1.set_title('A', loc='left')
ax2.set_title('B', loc='left')
plt.rcParams.update({'axes.titlesize' : 10 })
ax1.set_title('before drift-subtraction', loc='right')
ax2.set_title('after drift-subtraction', loc='right')
ax1.set_ylabel('$y$ ($\mathrm{\mu}$m)')
ax1.set_xlabel('$x$ ($\mathrm{\mu}$m)')
ax2.set_xlabel('$x$ ($\mathrm{\mu}$m)')
ax2.set_ylabel('')
plt.xticks(np.arange(0,120, step=20)) # order I call this matters
plt.yticks(np.arange(0,81, step=20))
#fig.subplots_adjust(hspace=0)
plt.xlim(xmax=80)
#plt.ylim()
print('Figure 3 in EPJ paper')
thisheight=2.2
thiswidth=4.3
fig.set_figheight(thisheight)
fig.set_figwidth(thiswidth)
ax1.tick_params(width=.2)
ax2.tick_params(width=.2)
plt.tight_layout()
os.chdir('C:\\Users\\Viva\\Desktop\\EPJ folder\\paperfigures')
try:
plt.savefig('t1_and_tm_drifty,' + moviename + '.pdf',
bbox_inches='tight', figsize=(thiswidth, thisheight))
plt.savefig('t1_and_tm_drifty,' + moviename + '.svg',
bbox_inches='tight', figsize=(thiswidth, thisheight))
print('pdf saved')
plt.savefig('t1_and_tm_drifty,' + moviename + '.png',
bbox_inches='tight', dpi=600, figsize=(thiswidth, thisheight))
except IOError:
print('Close the pdf file so I can overwrite it.')
In [51]:
tp.plot_traj(t1_drifty, mpp = scaling, legend=False)
Out[51]:
In [52]:
d_driftycontrol = tp.compute_drift(t1control, smoothing=15)
#plt.figure()
d_driftycontrol.plot(grid=False)
plt.title('Translational drift in ' + controlmoviename + '\n')
Out[52]:
In [53]:
t1control_drifty = t1control[t1control['frame'] > 900]
tmcontrol_drifty = tmcontrol[tmcontrol['frame'] > 900]
t1control_drifty = t1control_drifty[t1control_drifty['frame'] < 1100]
tmcontrol_drifty = tmcontrol_drifty[tmcontrol_drifty['frame'] < 1100]
In [54]:
plt.axis('equal')
ax = tp.plot_traj(t1control_drifty, mpp = scaling, legend=False)
In [55]:
plt.axis('equal')
ax = tp.plot_traj(tmcontrol_drifty, mpp = scaling, legend=False)
This shows that the control drifts too, which makes sense since the oil can evaporate.